package com.agentframework.examples.jinhua;

import com.agentframework.core.action.BeanOutputAbstractAction;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 诈金花荷官动作基类，提供格式约束和消息处理框架
 * @author wangjun
 */
public abstract class JinhuaDealerAction extends BeanOutputAbstractAction {

    protected final JinhuaTool jinhuaTool;
    
    public JinhuaDealerAction(String actionName, JinhuaTool jinhuaTool) {
        super(actionName);
        this.jinhuaTool = jinhuaTool;
    }

    protected List<String> getPlayerIdList() {
        return getJinhuaGameState().getPlayerList().stream().map(PlayerInfo::getPlayerId).toList();
    }

    protected Set<String> getPlayerIds() {
        return new HashSet<>(getPlayerIdList());
    }

    protected String getDealerAgentId() {
        return getJinhuaGameState().getDealerAgent().getAgentId();
    }

    protected boolean isRoundOver() {
        return getJinhuaGameState().isRoundOver();
    }

    protected JinhuaGameState getJinhuaGameState() {
        return ((JinhuaEnvironment) getEnvironment()).getJinhuaGameState();
    }

} 